package cn.rengy.web.framework.wxmp.token;

import cn.rengy.lang.WeChatException;
import cn.rengy.tpa.wxmp.token.AccessToken;

public class AccessTokenImpl implements AccessToken {

	private String tokenValue;
	private TokenService tokenService;
	private String appid;
	
	public AccessTokenImpl(TokenService tokenService,String appid){
		this.tokenService=tokenService;
		this.appid=appid;
	}
	
	@Override
	public String token() throws WeChatException {
		tokenValue=tokenService.acquire(appid);
		return tokenValue;
	}

	@Override
	public void refresh() throws WeChatException {
		tokenService.evict(appid, tokenValue);
	}
	

}
